package com.citrix.gs.hello;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import eu.bitwalker.useragentutils.UserAgent;

import java.io.IOException;
import java.util.Enumeration;

/**
 * Created by yzhou-citrix on 10/23/15.
 */
@SuppressWarnings("serial")
public class HelloServlet extends HttpServlet{
    @Override
    protected void doGet(HttpServletRequest httpServletRequest, HttpServletResponse httpServletResponse) throws ServletException, IOException {
    	
        
        System.out.println("Enter get hello");
        
        String userAgentString = httpServletRequest.getHeader("User-Agent");
        
        UserAgent userAgent = UserAgent.parseUserAgentString(userAgentString);
        
        System.out.println(userAgent.getBrowser());
        System.out.println(userAgent.getBrowserVersion());
        System.out.println(userAgent.getOperatingSystem());
        //System.out.println(userAgent)
        
        /*
        Enumeration<String> headerNames = httpServletRequest.getHeaderNames();

        while (headerNames.hasMoreElements()) {

            String hName = headerNames.nextElement();
            System.out.println("http request (head, value): " + hName + "," + httpServletRequest.getHeader(hName));
        }*/

        httpServletResponse.getWriter().print("Hello, this is a Maven Web project implemented in IntelliJ");
    }
}
